<template lang="pug">
.evaluate-factor-add-wrap
  el-from(ref="from", :model="params", label-width="80px")
    el-from-item(label="因素所属题库：")
      el-select(v-model="params.questionId")
        option(label="1", value="1")
    el-from-item(label="因素级别")
      el-radio-group(v-model="params.level")
        el-radio(:label="1") 一级因素
        el-radio(:label="2") 二级因素
    el-from-item(label="因素名称")
      el-input(v-model="params.name")
    el-from-item(label="因素符号")
      el-input(v-model="params.symbol")
    el-form-item
      el-button(type="primary" @click="save") 保存
</template>

<script>
import mapStateModel from '../../utils/mapStateModel'
import { mapActions,mapState } from "vuex"
export default {
  data () {
    return {
      params: {
        name: '',
        symbol: '',
        questionId: '',
        level: ''
      },
      factorId: ''
    }
  },
  computed: {
    ...mapState('question', {
      questionList: state => state.questionList
    })
  },
  props: {
    updateDate: {
      type: Object
    }
  },
  mounted () {
    this.index();
  },
  methods: {
    ...mapActions('factor', ['create', 'update']),
    ...mapActions('question', ['index']),
    // 保存
    save () {
      if (factorId) {
        this.create(this.params)
      } else {
        this.update(this.factorId, this.params)
      }
    },

    // 修改数据初始化
    changeInit (opts) {
      for (let key in this.params) {
        this.params[key] = opts[key]
      }
      this.factorId = option.id
    }

  },
  watch: {
    updateDate: 'changeInit'
  }
}
</script>


<style lang="stylus">
</style>
